package cz.hanis.android.geography.adapters;

import java.util.Collections;
import java.util.List;


import cz.hanis.android.geography.R;
import cz.hanis.android.geography.models.Test;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class TestSpinnerAdapter extends ArrayAdapter<String> {

	private LayoutInflater inflater;

	private List<Test> tests;

	public TestSpinnerAdapter(Context context, int textViewResourceId, List<Test> tests) {
		super(context, textViewResourceId);		
		this.tests = tests;
		inflater = ((Activity) context).getLayoutInflater();
//		for(Test test : tests) {
//			add(test.getName());
//		}
//		super.notifyDataSetChanged();
	}

	
	
	
	@Override
	public int getCount() {
		return tests.size();
	}




	@Override
	public View getDropDownView(int position, View convertView, ViewGroup parent) {
		return getCustomView(position, convertView, parent);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		return getCustomView(position, convertView, parent);
	}

	public View getCustomView(int position, View convertView, ViewGroup parent) {

		View row = inflater.inflate(R.layout.test_row, parent, false);
		TextView name = (TextView) row.findViewById(R.id.tr_name);
		name.setText(tests.get(position).getName());

		TextView description = (TextView) row
				.findViewById(R.id.tr_description);
		description.setText(tests.get(position).getDescription());

		return row;
	}
}